<?php

class spPage extends spDiv
{
	private $toolbar = null;

	public function __construct( $param=null )
	{
		parent::__construct();
		parent::setClass( "spPage wrap" );
	}
	
	public function getToolBar()
	{
		return $this->toolbar;
	}
	
	public function spRenderDefaults()
	{
		parent::addChild( new spDiv(array(
			"id" => "spErrorMsg"
		)));
		
		$dialog = new spDiv(array(
			"id" => "spDialogModal"
		));
		$dialog->addChild( new spImage(array(
			"src" => get_option('home')."/wp-content/plugins/sigmaphp/images/ajax-loader.gif"
		)));
		parent::addChild( $dialog );
	}

	public function spRenderHeading_org( $title, $imgsrc=null )
	{
		$d = new spDiv;
		
		if ( $imgsrc!=null )
		{
			$d->addChild(new spImage(array(
				"src" => $imgsrc
			)));
		}
			
		$d->addChild(new spHeading(array(
			"content" => $title
		)));
		$d->addChild( new spHorizontalLine );
		parent::addChild( $d );
	}

	public function spRenderHeading_withtext( $title, $imgsrc=null )
	{
		$container = new spDiv;
	
		$d = new spHeading;
		
		if ( $imgsrc!=null )
		{
			$d->addChild(new spImage(array(
				"src" => $imgsrc,
				"style" => array(
					"vertical-align" => "baseline"
				)
			)));
		}
		
		$d->addChild( new spElement( null, array(
			"content" => $title
		)) );
		
		$container->addChild( $d );

		$container->addChild( new spHorizontalLine );
		
		parent::addChild( $container );
	}

	public function spRenderHeading( $title, $imgsrc=null )
	{
		$right = new spImage(array(
			"src" => $imgsrc
		));
		
		$left = new spHeading(array(
			"content" => $title
		));
	
		$table = new spTable(array(
			"style" => array(
				"width" => "100%"
			)
		));
		$row = $table->addRow();

		$row->addTableData(new spTableData(array(
			"child" => $left,
			"style" => array(
				"vertical-align" => "bottom"
			)
		)));

		$row->addTableData(new spTableData(array(
			"child" => $right,
			"style" => array(
				"vertical-align" => "bottom",
				"text-align" => "right"
			)
		)));
		
		parent::addChild( $table );
		
		parent::addChild( new spHorizontalLine );
		
		// toolbar placeholder
		parent::addChild( $this->toolbar = new spDiv(array(
		)));
		
	}
	
	/*
	public function spRenderHeading( $title, $imgsrc=null )
	{
		$d = new spDiv(array(
			"style" => array(
				"position" => "relative"
			)
		));
		
		if ( $imgsrc!=null )
		{
			$d->addChild(new spImage(array(
				"src" => $imgsrc,
				"style" => array(
					"float" => "left"
				)
			)));
		}		
			
		$cc = new spDiv(array(
			"style" => array(
				"bottom" => "0",
				"position" => "absolute"
			)
		));
			
		$cc->addChild(new spHeading(array(
			"content" => $title,
			"style" => array(
	//			"bottom" => "0",
		//		"position" => "absolute"
			)
		)));
		
		$d->addChild( $cc );
		
		$d->addChild( new spHorizontalLine(array(
			"style" => array(
				"clear" => "both"
			)
		)) );
		parent::addChild( $d );
	}
	*/
	
	public function spCreateSubHeading( $title )
	{
		return new spHeading(array(
			"level" 	=> "2",
			"content" 	=> $title
		));
	}
	
	public function spRenderSubHeading( $title )
	{
		parent::addChild( self::spCreateSubHeading( $title ) );
	}
	
	public function render()
	{
		//spDebugProfiler::instance()->dump();
		parent::render();
	}
}

?>